from marshmallow import Schema
from flask_restplus import Namespace, fields


class DataCollectionSchemas(object):
    def __init__(self, namespace):
        self.ns = namespace

    def DataCollectionIdSchemas(self):
        return self.ns.model(
            "collection_id",
            {
                "id": fields.Integer(),
            },
        )

    def DataCollectionPostSchemas(self):
        return self.ns.model(
            "collection_post",
            {
                "create_time": fields.String(),
                "update_time": fields.String(),
                "area": fields.String(),
                "city": fields.String(),
                "work_type": fields.String(),
                "project_name": fields.String(),
                "course": fields.Integer(),
                "file_size": fields.Integer(),
                "file_num": fields.Integer(),
                "work_time": fields.Float(),
                "weather": fields.String(),
                "data_scene": fields.String(),
                "road_category": fields.String(),
                "collection_place": fields.String(),
                "follow_user": fields.String(),
                "remarks": fields.String(),
                "car": fields.Integer(),
            },
        )

    def DataCollectionListQuerySchemas(self):
        return {
            "page": "页数",
            "per_page": "页容量",
            "create_time": "采集时间",
            "update_time": "上传时间",
            "area": "省份",
            "city": "城市",
            "work_type": "作业类型",
            "project_name": "工程名",
            "course": "采集里程",
            "file_size": "文件大小",
            "file_num": "文件数量",
            "work_time": "作业时长",
            "weather": "天气",
            "data_scene": "数据场景",
            "road_category": "道路类别",
            "collection_place": "采集地点",
            "follow_user": "跟车人员",
            "car_num": "车辆编号",
            "start_time": "起始时间",
            "end_time": "结束时间",
        }

    def CarInfoSchemas(self):
        return self.ns.model(
            "car_info_body",
            {
                "id": fields.Integer(),
                "create_time": fields.DateTime(),
                "car_num": fields.String(),
                "asset_code": fields.String(),
                "vin_num": fields.String(),
            },
        )

    def CollectionImageCreateSchemas(self):
        return self.ns.model(
            "collection_images",
            {"id": fields.Integer(), "collection": fields.Integer(), "file": fields.String},
        )

    def CollectionImageIdSchemas(self):
        return self.ns.model("collection_image_id", {"id": fields.Integer()})

    def DataCollectionInfoSchemas(self):
        return self.ns.model(
            "collection_info",
            {
                "id": fields.Integer(),
                "create_time": fields.String(),
                "update_time": fields.String(),
                "area": fields.String(),
                "city": fields.String(),
                "work_type": fields.String(),
                "project_name": fields.String(),
                "course": fields.Integer(),
                "file_size": fields.Float(),
                "file_num": fields.Integer(),
                "work_time": fields.Float(),
                "weather": fields.String(),
                "data_scene": fields.String(),
                "road_category": fields.String(),
                "collection_place": fields.String(),
                "follow_user": fields.String(),
                "remarks": fields.String(),
                "cars": fields.Nested(self.CarInfoSchemas()),
                "images": fields.List(fields.Nested(self.CollectionImageCreateSchemas())),
            },
        )

    def DataCollectionBodySchemas(self):
        return self.ns.model(
            "List_body",
            {
                "total": fields.Integer(),
                "data": fields.List(fields.Nested(self.DataCollectionInfoSchemas())),
            },
        )
